-
Notifications
You must be signed in to change notification settings - Fork 5
Captcha V2 #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Captcha V2 #14
Conversation
perimeterx/px_blocker.py
Outdated
| headers = ctx.get('headers') | ||
| if ctx.get('block_action') is not 'r': | ||
| for item in headers.keys(): | ||
| if (item.lower() is 'accept' or item.lower() is 'content-type') and headers[item] is 'application/json': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers[item] may be a comma separated string, where application/json is just one element, so you should check if it's contained rather than equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| def is_json_response(self, ctx): | ||
| headers = ctx.get('headers') | ||
| if ctx.get('block_action') is not 'r': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you call is_json_response after the check in the main flow that block action is not r, so this is a bit redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not redundant, It sets the content-type, even if the block_Action is 'r' it will get there
| blocking_response = self.mustache_renderer.render(px_template.get_template(px_constants.BLOCK_TEMPLATE), blocking_props) | ||
| is_json_response = self.is_json_response(ctx) | ||
| if is_json_response: | ||
| content_type = 'application/json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's json response, then the response shouldn't be a compiled html template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.